import { FC } from "react"

import { useLocale } from "@/locales"

import TextInput from "../textInput"

const LoginIPInput: FC<any> = ({
	fieldName = "ip",
	isRequired = false,
	isHideLabel = false,
	rules: rulesProps,
	inputProps,
	placeholderId
}) => {
	const { formatMessage } = useLocale()
	const rules = isRequired
		? [
				{
					required: true,
					message: formatMessage({ id: "message.please_inter_sth" }, { sth: formatMessage({ id: "label.login_ip_whitelist" }) })
				}
		  ]
		: []

	return (
		<TextInput
			isHideLabel={isHideLabel}
			labelId="member.login_ip_member"
			placeholderId={placeholderId ? placeholderId : "label.please_input"}
			fieldName={fieldName}
			rules={rulesProps || rules}
			{...inputProps}
		/>
	)
}

export default LoginIPInput
